#ifndef __RenderQueueGroup_H__
#define __RenderQueueGroup_H__

#include "video/Renderable.h"
#include <vector>

namespace KEngine
{

class RenderQueue;
class RenderQueueGroup
{
public:
	typedef std::vector<Renderable*> RenderableList;

public:
	RenderQueueGroup(RenderQueue* parent);
	virtual ~RenderQueueGroup();

	void addRenderable(Renderable* renderable);
	void sort(Camera* cam);
	void clear();
	void renderObjectsList(Camera* camera, TimeValue t);

protected:
	struct DepthSortDescendingLess
	{
		Camera*	camera;

		DepthSortDescendingLess(Camera* cam)
			: camera(cam)
		{
		}

		bool operator()(const Renderable* a, const Renderable* b) const
		{
			// Sort by depth
			float adepth = a->getSquaredViewDepth(camera);
			float bdepth = b->getSquaredViewDepth(camera);

			// Sort DESCENDING by depth (i.e. far objects first)
			return adepth > bdepth;
		}
	};

protected:
	RenderableList mRenderableList;
};
}
#endif 